<template>
  <div class="u-p-20">
    <el-card shadow="never">
      <div slot="header">
        <b class="u-f-16">
          <span v-if="objForm.id">编辑</span>
          <span v-else>添加</span>活动
        </b>
        <div class="u-right u-5mt">
          <el-button
            type="success"
            size="small"
            icon="el-icon-document-checked"
            @click="submitForm('objForm')"
            v-if="hasPerm('activityEdit')"
          >提交保存</el-button>
          <el-button size="small" icon="el-icon-back" @click="$router.go(-1)">返回</el-button>
        </div>
      </div>
      <el-form :model="objForm" :rules="rules" ref="objForm" label-width="100px" class="u-form">
        <el-form-item label="活动名称">
          <el-input type="text" v-model="objForm.name"></el-input>
        </el-form-item>
        <el-form-item label="活动简介">
          <el-input type="textarea" v-model="objForm.intro"></el-input>
        </el-form-item>
        <el-form-item label="拼团等待时间">
          <el-col :span="18">
            <el-input type="text" v-model="objForm.condition_time" placeholder="单位（小时）"></el-input>
          </el-col>
          <el-col class="line" :span="2">-</el-col>
          <el-col :span="4">单位（小时）</el-col>
        </el-form-item>
        <el-form-item label="活动时间">
          <el-col :span="11">
            <el-date-picker
              type="date"
              placeholder="开始时间"
              v-model="objForm.start_time"
              value-format="timestamp"
              style="width: 100%;"
            ></el-date-picker>
          </el-col>
          <el-col class="line" :span="2">-</el-col>
          <el-col :span="11">
            <el-date-picker
              placeholder="结束时间"
              v-model="objForm.end_time"
              value-format="timestamp"
              style="width: 100%;"
            ></el-date-picker>
          </el-col>
        </el-form-item>
        <el-form-item label="是否启用">
          <el-switch
            v-model="objForm.status"
            active-color="#13ce66"
            :active-value="1"
            inactive-color="#666"
            :inactive-value="2"
          ></el-switch>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
import commonEdit from "@/mixins/common-edit";
export default {
  mixins: [commonEdit],
  data() {
    return {
      apiName: "activity",
      backRoute: "activityIndex", //成功跳转地址
      objForm: {
        id: "",
        name: "", //名称
        condition_time: 24, //单位小时
        intro: "", //简介
        start_time: "", //开始时间
        end_time: "", //结束时间
        status: 1 //状态
      }
    };
  },
  methods: {
    afterGetInfo() {
      //初始化-获取编辑数据
    }
  },
  created() {
    if (this.$route.params.id) {
      this.objForm.id = this.$route.params.id;
    }
  }
};
</script>
